class NodeIter():
    def __init__(self,node):
        self.curr_node = node

    def __next__(self):
        if self.curr_node is None:
            raise StopIteration
        node, self.curr_node = self.curr_node,self.curr_node.next

class Node():
    def __init__(self,name) -> None:
        print('__init__ Node')
        self._name = name
        self._next = None

    def __iter__(self):
        print('__iter__')
        return NodeIter(self)

node1 = Node('node1')


for node in node1:
    print(node.name)
    

